if ('https://fafasfsgif.com/picture.jpg'.match('.gif')) { // 隐式转换成正则对象
    console.log('a gif file');
} else {
    console.log('not a gif file');
}

// 'https://fafasfs.com/picture.jpg'.match(new RegExp('.gif'))
// 'https://fafasfs.com/picture.jpg'.match(/'.gif'/)